<!DOCTYPE html>
<html>
<head>
    <title>医院修改</title>
    {% include 'admin/common/header.html' %}
</head>
<body>
    <div class="mainBox">
        <table class="layui-table" style="width: auto; margin: 10px 10px 10px 10px;">
            <thead>
            <tr>
                <th width="100">样本名称</th>
                <th width="100">姓名</th>
                <th width="200">身份证</th>
                <th width="60">性别</th>
                <th width="60">检查号</th>
                <th width="150">检查时间</th>
                <th width="150">Dx</th>
                <th width="80">操作</th>
            </tr>
            </thead>
            <tbody>
            {% for record in record_list %}
            <tr>
                <input type="hidden" name="ids[]" value="{{ record.id }}">
                <td>{{ record.name }}</td>
                <td>{{ record.username }}</td>
                <td>{{ record.id_card }}</td>
                <td>{% if record.sex == 1 %}男{% endif %}{% if record.sex == 2 %}女{% endif %}</td>
                <td>{{ record.case_no }}</td>
                <td>{{ record.test_time }}</td>
                <td>{{ record.results }}</td>
                <td><a class="layui-btn layui-btn-sm td" data-id="{{ record.id }}" data-title="下载结果">下载报告</a></td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
{% include 'admin/common/footer.html' %}
<script>
    layui.use(['form', 'jquery'], function () {
        let form = layui.form;
        let $ = layui.jquery;

        $(".td").click(function (e) {
            let id = $(this).data("id");
            let that = this;
            $.ajax({
                url: '/admin/record/t_download',
                data: JSON.stringify({id: id}),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.success) {
                        window.location.href = result.data.src
                    }else{
                         layer.msg('网络错误', {icon: 2, time: 1000})
                    }
                    {#if (result.success) {
                        let record = result.data;
                        if (Object.keys(record).length > 0) {
                            $(that).parent().parent().find("input[name='username[]']").val(record.username)
                        }
                        $(that).parent().parent().find(".year").val(IdCard(id_card, 3))
                        let sex = IdCard(id_card, 2);
                        $(that).parent().parent().find("select[name='sex[]'] option").each(function (i, n) {
                            if ($(n).val() == sex) {
                                $(n).attr("selected", true);
                            }
                        })
                        layui.form.render("select");
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000})
                    }#}
                }
            })
        })
    })
</script>
<script>
</script>
</body>
</html>